package me.sdevil507.biz.fruit.po;

import lombok.Data;
import lombok.EqualsAndHashCode;
import me.sdevil507.supports.jpa.BaseJpaSnowflakeIdEntity;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: tips_back_end
 * @description: 成果作者
 * @author: kzl
 * @create: 2020-06-23 12:03
 **/

@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "biz_fruit_author")
@Where(clause="is_del = 0")
public class FruitAuthorPO extends BaseJpaSnowflakeIdEntity {

    /**
     * 成果id
     */
    @Column
    private Long  fruitId;


    @OneToMany(targetEntity = FruitAuthorOrgPO.class, cascade= CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name="authorId")
    @OrderBy("ranking ASC")
    private List<FruitAuthorOrgPO> orgPOList =new ArrayList<>();

    /**
     * 作者名称
     */
    @Column
    private String author;

    /**
     * 作者单位
     */
    @Column
    private String job;


    /**
     * 专家id
     */
    @Column
    private Long orgUserId;


    /**
     * 第几作者，排名1，则表示第一作者
     */
    @Column
    private int ranking;

    /**
     * 手机号码
     */
    @Column
    private String phoneNumber;

    /**
     * 是否删除
     */
    @Column(nullable = false)
    private Boolean  isDel= false;

    /**
     * 创建时间
     */
    @Column
    private Date createTime = new Date();

    /**
     * 更新时间
     */
    @Column
    private Date updateTime = new Date();

    /**
     * 智库id
     */
    @Column
    private Long orgId;


    /**
     * 著作方式
     */
    @Column
    private String writeType;

    /**
     * 著作方式
     */
    @Formula("(select t.d_name from biz_sysdict as t  where t.d_value=write_type and t.type_key='writeType')")
    private String writeTypeName;

    /**
     * 作者数量
     */
    @Column
    private String number;

    /**
     * 是否临时专家
     */
    @Column
    private Boolean  isTemp;
    /**
     * 专家观点
     */
    @Column
    private String viewPoint;
}

